package com.example.xViewChat.UI.Adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.example.xViewChat.R;
import io.ganguo.chat.route.biz.entity.User;

import java.util.List;

/**
 * Created by hasee on 2016-04-14.
 */
public class FriendListAdapter extends BaseAdapter {
    private List<User> mFriendList;
    private LayoutInflater mInflater;
    public FriendListAdapter(Context mContext, List<User> mFriendList) {
        this.mFriendList=mFriendList;
        this.mInflater=LayoutInflater.from(mContext);
    }

    @Override
    public int getCount() {
        return mFriendList.size();
    }

    @Override
    public Object getItem(int position) {
        return mFriendList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ImageView avatarView;
        TextView nameView;
        ImageView isOnline;
        TextView introView;
        convertView = mInflater.inflate(R.layout.friend_list_item,null);
        User user = mFriendList.get(position);
        String name=user.getAccount();

        avatarView = (ImageView) convertView
                .findViewById(R.id.user_photo);
        nameView = (TextView) convertView
                .findViewById(R.id.friend_list_name);
        isOnline = (ImageView)convertView.findViewById(R.id.stateicon);

        introView = (TextView) convertView
                .findViewById(R.id.friend_list_brief);
        nameView.setText(name);
        return convertView;
    }
}
